package dp.一维数组;


/**
 * https://leetcode.cn/problems/jump-game/
 *
 * 题解：https://mp.weixin.qq.com/s?__biz=MzAxODQxMDM0Mw==&mid=2247485087&idx=1&sn=ddbed992e5ad8f1aa3b3d4afcb17889b&scene=21#wechat_redirect
 *
 * https://mp.weixin.qq.com/s?__biz=MzAxODQxMDM0Mw==&mid=2247493680&idx=1&sn=5e5a9fac421ca026ec3487a2b8b4520c&chksm=9bd41638aca39f2ee76190ff7f19fe87316060798bd27d40554a415eee64613a7c5ad3e4f55c&scene=178&cur_album_id=2165170016067944448#rd
 */
public class _55_跳跃游戏 {

    public boolean canJump(int[] nums) {
        int fastest = 0;
        for (int i = 0; i < nums.length - 1; i++) {
            fastest = Math.max(fastest, i + nums[i]);
            if (fastest <= i) return false;
        }
        return fastest >= nums.length - 1;
    }
}
